package com.qulai.web.controller.basic;

import com.qulai.amazon_us.domain.basic.dashboard.ProductChangeDTO;
import com.qulai.amazon_us.domain.basic.dashboard.RemainUploadDTO;
import com.qulai.amazon_us.domain.basic.dashboard.ShopStockStatsDTO;
import com.qulai.amazon_us.service.basic.IDashboardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@RequestMapping("/api/dashboard")
public class DashboardController {

    @Autowired
    private IDashboardService dashboardService;

    @GetMapping("/product_change")
    public ResponseEntity<List<ProductChangeDTO>> getProductChange(
            @RequestParam String timeType,
            @RequestParam String startTime,
            @RequestParam String endTime,
            @RequestParam(required = false) String className,
            @RequestParam(required = false) String platform) {
        List<ProductChangeDTO> data = dashboardService.getProductAddChange(timeType, startTime, endTime, className, platform);
        return ResponseEntity.ok(data);
    }


    @GetMapping("/remain_upload")
    public ResponseEntity<List<RemainUploadDTO>> getRemainUpload(@RequestParam String platform, @RequestParam String brand) {
        List<RemainUploadDTO> data = dashboardService.getRemainUpload(platform, brand);
        return ResponseEntity.ok(data);
    }


    @GetMapping("/shopStockStats")
    public ResponseEntity<List<ShopStockStatsDTO>> getShopStockStats(@RequestParam(required = false) String platform,
                                                                     @RequestParam(required = false) String timeType,
                                                                     @RequestParam(required = false) String startTime,
                                                                     @RequestParam(required = false) String endTime) {
        List<ShopStockStatsDTO> data = dashboardService.getShopStockStats(platform, timeType, startTime, endTime);
        return ResponseEntity.ok(data);
    }


}